package com.dlc.felear.xiaoensale.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.dlc.felear.xiaoensale.R;
import com.dlc.felear.xiaoensale.deviceUtil.TopbarHelper;
import com.dlc.felear.xiaoensale.entity.CookingMenu;
import com.dlc.felear.xiaoensale.helper.JsonHelper;
import com.itdlc.android.library.base.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 标准菜谱信息页面
 */
public class StdEmnuInfoActivity extends BaseActivity {

    private static final String TAG = "StdEmnuInfoActivity";
    @BindView(R.id.e_iv_pic)
    ImageView pic;
    @BindView(R.id.e_tv_name)
    TextView etName;
    @BindView(R.id.e_tv_pname)
    TextView etPName;
    @BindView(R.id.e_tv_duration)
    TextView etDuration;
    @BindView(R.id.e_tv_size)
    TextView etSize;
    private CookingMenu cookingMenu;
    private TopbarHelper topbarHelper;

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_std_emnu_info;
    }

    @Override
    protected void initialView() {
        topbarHelper = new TopbarHelper(this);
        topbarHelper.setNavActivity(MenuListActivity.class);
        topbarHelper.setcon(R.drawable.arrow_left);
        topbarHelper.setTitle("标准菜谱信息");
    }

    @Override
    protected void initData() {
        cookingMenu = (CookingMenu) getIntent().getSerializableExtra("id");
        Log.e(TAG, JsonHelper.toJson(cookingMenu));
        if (cookingMenu != null) {
            etName.setText(cookingMenu.getName());
            etDuration.setText(Integer.toString(cookingMenu.getDuration()));
            etSize.setText(cookingMenu.getSpecification() + " 斤");
            if (TextUtils.isEmpty(cookingMenu.getPic())) {
                Glide.with(this).load(R.drawable.xhscjd).into(pic);
            } else {
                Glide.with(this).load(cookingMenu.getPic()).into(pic);
            }
        }
    }

    @OnClick({R.id.e_tv_cpwt})
    public void clickView(View view) {
        switch (view.getId()) {
            case R.id.e_tv_cpwt:
                Intent intent = new Intent(this, MiroEditMenuActivity.class);
                intent.putExtra("cookingMenu", cookingMenu);
                intent.putExtra("src", 1);
                startActivity(intent);
                break;
        }
    }
}